<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="order/include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5></h5>
				</div>
				<div class="ibox-content">
					<form class="form-horizontal m-t" id="signupForm">
						<input type="hidden" th:value="${order.id}" id="id" name="id">

<!--						<div class="form-group">-->
<!--							<label class="col-sm-3 control-label">-->
<!--								<em class="gg-star">*</em>物流公司：-->
<!--							</label>-->
<!--							<div class="col-sm-8">-->
<!--								<input type="text" name="expresscom" id="expresscom" value="" class="form-control"-->
<!--									   th:value="${order.expresscom}" placeholder="物流公司">-->
<!--							</div>-->
<!--						</div>-->

<!--						<div class="form-group">-->
<!--							<label class="col-sm-3 control-label">-->
<!--								<em class="gg-star">*</em>物流单号：-->
<!--							</label>-->
<!--							<div class="col-sm-8">-->
<!--								<input type="text" name="expresssn" id="expresssn" value="" class="form-control"-->
<!--									   th:value="${order.expresssn}" placeholder="物流单号">-->
<!--							</div>-->
<!--						</div>-->

<!--						<div class="form-group">-->
<!--							<label class="col-sm-3 control-label">-->
<!--								图片：-->
<!--							</label>-->
<!--							<div class="col-sm-8">-->
<!--								<input type="text" name="thumb" id="thumb" value="" class="form-control"-->
<!--									   th:value="${order.logisticsImage}"  autocomplete="off" readonly>-->
<!--								<div class="input-group " style="margin-top:.5em;">-->
<!--									<img th:src="@{${order.logisticsImage}}" id="thumbImg" style="max-width: 30%"/>-->
<!--								</div>-->
<!--							</div>-->
<!--							<div class="col-sm-1">-->
<!--								<button class="btn btn-sm btn-default" type="button"  style="padding:7px 10px"-->
<!--										onclick="onSelectImgBtnClick('thumb','thumbImg')">选择图片</button>-->
<!--							</div>-->
<!--						</div>-->

						<div class="form-group text-center">
							<div class="col-sm-8 col-sm-offset-2">
								<button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>提交</button>
								<div class="btn btn-danger" onclick="closeDow()">
									<i class="fa fa-remove"></i> 关闭
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<div th:include="order/include::footer"></div>

<script type="text/javascript">
    $().ready(function() {
        validateRule();
    });

    $.validator.setDefaults({
        submitHandler : function() {
            uploadLogisticsImage();
        }
    });
    function closeDow() {
        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
        parent.layer.close(index);
    }

    function onSelectImgBtnClick(inputId, imgId) {
        layer.open({
            id:'selectImg',
            type : 2,
            title : '选择图片',
            maxmin : true,
            shadeClose : false,
            area : [ '60%', '70%' ],
            content : '/platform/config/selectImg/' + inputId +"/"+ imgId // iframe的url
        });
    }

    /**
     * 加载图片URL
     * @param inputId
     * @param imgId
     * @param url
     */
    function loadImgUrl(inputId, imgId, url) {
        $('#'+inputId +'').val(url);
        $('#'+imgId +'').attr('src', url);
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules : {
                // thumb : {
                //     required : true
                // },
                expresssn : {
                    required : true
                },
                expresscom : {
                    required : true
                }
            },
            messages : {
                // thumb : {
                //     required : icon + "请选择要上传的图片"
                // },
                expresssn : {
                    required : icon + "请填写物流单号"
                },
                expresscom : {
                    required : icon + "请填写物流公司"
                }
            }
        })
    }

    /**
     * 上传物流单图片
     */
    function uploadLogisticsImage() {
        $.ajax({
            url: "/order/manage" + "/uploadLogisticsImage",
            type: "POST",
            data: {
                id: $('#id').val(),
                logisticsImage: $('#thumb').val(),
                expresssn: $('#expresssn').val(),
                expresscom: $('#expresscom').val()
            },
            success: function (r) {
				parent.layer.msg(r.msg);
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);
			}
        });
    }
</script>
</body>

</html>
